package framework.web;

import framework.pojo.Page;
import framework.service.RecordService;
import framework.service.impl.RecordServiceImp;
import framework.utils.WebUtils;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class RecordServlet extends BaseServlet {

    RecordService recordService = new RecordServiceImp();


    protected void GetRecord(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        Integer uid = WebUtils.parseInt(req.getParameter("uid"), 0);
        if(uid==0)
            uid=null;

        Integer page_id;
        if (req.getParameter("page_id") == null)
            page_id = 1;
        else page_id = WebUtils.parseInt(req.getParameter("page_id"), 0);

        Boolean stat = WebUtils.StrToBool(req.getParameter("stat"));

//        req.setAttribute("stat", stat);

        Page p = recordService.GetRecord(uid, stat, page_id, 10000);

        p.setUrl("record/ItemServlet?action=page");


        req.setAttribute("page", p);
        req.getRequestDispatcher("/page/user/record.jsp").forward(req, resp);
    }

}
